define(["app", "angular", "services/BaseService"], function(app, angular) {
	
	var deps = ["$http", "BaseService"];
	
	function yokiCountryResource($http, BaseService) {
        return initResource($http, BaseService.restfulUrl + "country/", BaseService.formHeader);
    }
	
	var postHeader = {
	        "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8"
	};
	
	function initResource($http, preUrl,formHeader) {
        return {
        	save: function (countryVo,formData) {
				//return $http.post(preUrl + "saveCountry?countryName="+countryVo.countryName);
				return $http.post(preUrl + "saveCountry?countryName="+countryVo.countryName+"&continentId="+countryVo.continentId,formData,  {
					transformRequest: angular.identity,
					headers: {
                        "Content-Type": undefined
                    },
                    transformResponse: function (data) {
                        return {
                            fileId: data
                        };
                    }
				});
			},
			uploadFile: function (type,formData) {
				//return $http.post(preUrl + "saveCountry?countryName="+countryVo.countryName);
				return $http.post(preUrl + "uploadFile?type="+type,formData,  {
					transformRequest: angular.identity,
					headers: {
                        "Content-Type": undefined
                    },
                    transformResponse: function (data) {
                        return {
                            fileId: data
                        };
                    }
				});
			},
			
			
			
			deleteCountry:function(countryId){
                return $http.get(preUrl +countryId+ "/deleteCountry");
            },
            queryCountryList: function (pageNo,pageSize) {
                return $http.get(preUrl + "queryCountryList", {
                    params: {
                        pageSize: pageSize || 10000,
                        pageNo: pageNo || 1
                    }
                });
            },
        };
        
    }
	yokiCountryResource.$inject = deps;
	app.lazy.factory("AddYokiCountryResource", yokiCountryResource);
});
